<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('班级信息列表')" />
</head>
<body class="gray-bg">
     <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="formId">
                    <div class="select-list">
                        <ul>

                            <li>
                                <label>班级名称：</label>
                                <input type="text" name="className"/>
                            </li>

                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>

            <div class="btn-group-sm" id="toolbar" role="group">
                <a class="btn btn-success" onclick="$.operate.addTab()" shiro:hasPermission="school:classInfo:add">
                    <i class="fa fa-plus"></i> 添加
                </a>

                <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="school:classInfo:remove">
                    <i class="fa fa-remove"></i> 删除
                </a>
                <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="school:classInfo:export">
                    <i class="fa fa-download"></i> 导出
                </a>
            </div>
            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('school:classInfo:edit')}]];
        var removeFlag = [[${@permission.hasPermi('school:classInfo:remove')}]];
        var prefix = ctx + "school/classInfo";
        var statusDatas = [[${@dict.getType('sys_data_status')}]];
        $(function() {
            var options = {
                url: prefix + "/list",
                createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
                exportUrl: prefix + "/export",
                modalName: "班级信息",
                columns: [{
                    checkbox: true
                },
                {
                    field: 'id', 
                    title: '班级编号'
                },
                {
                    field: 'className', 
                    title: '班级名称'
                },
                {
                    field: 'teacherName',
                    title: '班主任'
                },
                {
                    field: 'gradeName',
                    title: '所属年级'
                },
                {
                    field: 'comeYear',
                    title: '入学年份'
                },
                {
                    field: 'studentCount',
                    title: '学生数量'
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-primary btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="setTeacher(\'' + row.id + '\')"><i class="fa fa-user"></i>设置老师</a> ');
                        actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.editTab(\'' + row.id + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                        actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa-remove"></i>删除</a>');
                        actions.push('<a class="btn btn-primary btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="setBW(\'' + row.id + '\')"><i class="fa fa-user"></i>设置班委</a> ');
                        actions.push('<a class="btn btn-info btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="setDuty(\'' + row.id + '\')"><i class="fa fa-list"></i>设置值日表</a> ');
                        return actions.join('');
                    }
                }]
            };
            $.table.init(options);
        });

        function setTeacher(classId) {

            $.modal.openTab("任课老师", ctx + "school/relation/?classId="+classId);
        }
        function setBW(classId) {
            $.modal.openTab("班委信息", ctx + "school/committee/?classId="+classId);
        }
        function setDuty(classId) {
            $.modal.openTab("值日表", ctx + "school/table/?classId="+classId);
        }
    </script>
</body>
</html>